<template>
	<view class="tab-container">
		<!-- 导航按钮 -->
		<view class="tab-nav">
			<view v-for="(item, index) in tabList" :key="index" class="tab-button"
				:class="[currentIndex === index ? 'active' : '']" @tap="handleSwitch(index)">
				{{item.id}}
			</view>
		</view>

		<!-- 滑动内容区域 -->
		<swiper class="tab-content" :current="currentIndex" @change="swiperChange" :duration="300"
			:disable-touch="false">
			<swiper-item v-for="(item, index) in tabList" :key="index">
				<view class="content-item">
					<image :src="item.image" mode="aspectFit" class="content-image" :lazy-load="true" />
				</view>
			</swiper-item>
		</swiper>
		<!-- <view class="content-left">

		</view> -->
		<view class="content-right">
			<view>
				<image src="../../../static/blind/kxjs.png" class="right-kx"></image>
			</view>
			<view>
				<image src="../../../static/blind/ljdh.png" class="right-lj"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import k1 from "../../../static/blind/k1.png"
	import k2 from "../../../static/blind/k2.png"
	import k3 from "../../../static/blind/k3.png"
	import k4 from "../../../static/blind/k4.png"
	import k5 from "../../../static/blind/k5.png"
	import k6 from "../../../static/blind/k6.png"
	import k7 from "../../../static/blind/k7.png"
	export default {
		data() {
			return {
				currentIndex: 0,
				tabList: [{
						image: k1,
						id: "通1"
					},
					{
						image: k2,
						id: "通2"
					},
					{
						image: k3,
						id: "通3"
					},
					{
						image: k4,
						id: "通4"
					},
					{
						image: k5,
						id: "通5"
					},
					{
						image: k6,
						id: "通6"
					},
					{
						image: k7,
						id: "通7"
					}
				]
			}
		},
		methods: {
			handleSwitch(index) {
				if (this.currentIndex === index) return
				this.currentIndex = index
			},
			swiperChange(e) {
				this.currentIndex = e.detail.current
			}
		}
	}
</script>

<style lang="scss" scoped>
	/* 使用rpx适配多端 */
	$active-color: #644ddd;

	.tab-container {
		position: relative;
		width: 100%;
		height: 100%;
		padding: 30rpx;
		height: 400px;
	}

	.tab-nav {
		display: flex;
		width: 84%;
		margin: 0 auto;
		border-radius: 20px;
		justify-content: center;
		margin-bottom: 40rpx;
		border: 1px solid #644ddd;
	}

	.tab-button {
		width: 45px;
		height: 28px;
		border-radius: 30px;
		transition: all 0.3s ease;
		color: #fff;
		text-align: center;
		font-size: 15px;
		line-height: 28px;

		&.active {
			background-color: $active-color;
			transform: scale(1.1);
		}
	}

	.tab-content {
		width: 100%;
		height: 100%;
		overflow: hidden;
		border-radius: 24rpx;
	}

	.content-item {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.content-image {
		max-width: 100%;
		max-height: 280px;
		transition: opacity 0.3s;
		position: relative;
		top: 45px;
		animation: pulse-scale 3s infinite;
		cursor: pointer;
		z-index: 99;

		&.loaded {
			opacity: 1;
		}
	}

	@keyframes pulse-scale {
		0% {
			transform: scale(1);
		}

		50% {
			transform: scale(1.05);
		}

		100% {
			transform: scale(1);
		}
	}

	/* 悬停时暂停动画 */
	.content-image:hover {
		animation-play-state: paused;
		transform: scale(1.08);
	}


	.content-right {
		position: absolute;
		top: 120px;
		right: 10px;

		.right-kx {
			width: 114rpx;
			height: 113rpx;
		}

		.right-lj {
			margin-top: 10px;
			width: 114rpx;
			height: 113rpx;
		}
	}
</style>